<!DOCTYPE html>


  <html class="dark page-post">


<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>图解前端性能优化 | Poetry&#39;s Blog</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="性能优化,">
  

  <meta name="description" content="一、css和js的装载与执行1.1 HTML 页面加载渲染的过程 1.2 HTML渲染过程的一些特点 1.3 css 阻塞和 js 阻塞1.3.1 CSS阻塞 1.3.2 JS阻塞 二、资源的压缩与合并2.1 文件合并 2.2 css、js 及 HTML压缩2.2.1 CSS压缩 2.2.2 JS压缩 2.2.3 HTML压缩 2.3 http 清求的过程及潜在的性能优化点  三、图片相关的优化3">
<meta name="keywords" content="性能优化">
<meta property="og:type" content="article">
<meta property="og:title" content="图解前端性能优化">
<meta property="og:url" content="http://blog.poetries.top/2018/01/12/fed-performance-optimization/index.html">
<meta property="og:site_name" content="Poetry&#39;s Blog">
<meta property="og:description" content="一、css和js的装载与执行1.1 HTML 页面加载渲染的过程 1.2 HTML渲染过程的一些特点 1.3 css 阻塞和 js 阻塞1.3.1 CSS阻塞 1.3.2 JS阻塞 二、资源的压缩与合并2.1 文件合并 2.2 css、js 及 HTML压缩2.2.1 CSS压缩 2.2.2 JS压缩 2.2.3 HTML压缩 2.3 http 清求的过程及潜在的性能优化点  三、图片相关的优化3">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/119.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/120.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/121.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/122.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/123.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/124.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/125.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/126.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/127.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/128.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/129.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/130.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/131.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/132.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/133.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/134.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/135.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/136.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/137.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/138.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/139.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/140.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/141.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/142.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/143.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/144.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/145.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/146.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/147.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/148.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/149.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/150.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/151.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/152.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/153.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/154.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/155.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/156.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/157.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/158.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/159.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/160.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/161.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/162.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/163.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/164.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/165.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/166.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/167.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/168.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/169.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/170.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/171.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/172.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/173.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/174.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/175.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/176.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/177.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/178.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/179.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/180.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/181.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/182.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/183.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/184.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/185.png">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/186.png">
<meta property="og:image" content="https://camo.githubusercontent.com/db045941b5adebe26eae1202b9286fe8c39e5fa2/687474703a2f2f75706c6f61642d696d616765732e6a69616e7368752e696f2f75706c6f61645f696d616765732f3934383631342d313735326635633839393363633161302e6a7065673f696d6167654d6f6772322f6175746f2d6f7269656e742f7374726970253743696d61676556696577322f322f772f31323430">
<meta property="og:updated_time" content="2020-08-15T04:25:31.906Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="图解前端性能优化">
<meta name="twitter:description" content="一、css和js的装载与执行1.1 HTML 页面加载渲染的过程 1.2 HTML渲染过程的一些特点 1.3 css 阻塞和 js 阻塞1.3.1 CSS阻塞 1.3.2 JS阻塞 二、资源的压缩与合并2.1 文件合并 2.2 css、js 及 HTML压缩2.2.1 CSS压缩 2.2.2 JS压缩 2.2.3 HTML压缩 2.3 http 清求的过程及潜在的性能优化点  三、图片相关的优化3">
<meta name="twitter:image" content="https://poetries1.gitee.io/img-repo/2019/10/119.png">

  

  
    <link rel="icon" href="/favicon.ico">
  

  <link href="/css/styles.css?v=c114cbeddx" rel="stylesheet">
<link href="/css/other.css?v=c114cbeddx" rel="stylesheet">


  
    <link rel="stylesheet" href="/css/personal-style.css">
  

  

  
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?40b1f89aa80f2527b3db779c6898c879";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>


  
  <script type="text/javascript">
	(function(){
	    var bp = document.createElement('script');
	    var curProtocol = window.location.protocol.split(':')[0];
	    if (curProtocol === 'https') {
	        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
	    }
	    else {
	        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
	    }
	    var s = document.getElementsByTagName("script")[0];
	    s.parentNode.insertBefore(bp, s);
	})();
  </script>



  
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
  

  <!-- 聊天系统 -->
  
    
   <link type="text/css" rel="stylesheet" href="/renxi/default.css">
   <style>
      #modal {
        position: static !important;
      }
      .filter {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #fe5757;
        animation: colorChange 30s ease-in-out infinite;
        animation-fill-mode: both;
        mix-blend-mode: overlay;
      }
  
      @keyframes colorChange {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: .9;
        }
      }
   </style>
</head>
</html>
<body>
  
  
    <span id="toolbox-mobile" class="toolbox-mobile">导航</span>
  

  <div class="post-header CENTER">
   
  <div class="toolbox">
    <a class="toolbox-entry" href="/">
      <span class="toolbox-entry-text">导航</span>
      <i class="icon-angle-down"></i>
      <i class="icon-home"></i>
    </a>
    <ul class="list-toolbox">
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/archives/"
            rel="noopener noreferrer"
            target="_self"
            >
            博客
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/categories/"
            rel="noopener noreferrer"
            target="_self"
            >
            分类
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/tags/"
            rel="noopener noreferrer"
            target="_self"
            >
            标签
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/search/"
            rel="noopener noreferrer"
            target="_self"
            >
            搜索
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/link/"
            rel="noopener noreferrer"
            target="_self"
            >
            友链
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/about/"
            rel="noopener noreferrer"
            target="_self"
            >
            关于
          </a>
        </li>
      
    </ul>
  </div>


</div>


  <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录<i class="iconfont toc-title" style="display:inline-block;color:#87998d;width:20px;height:20px;">&#xf004b;</i></strong>
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#一、css和js的装载与执行"><span class="toc-text">一、css和js的装载与执行</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-HTML-页面加载渲染的过程"><span class="toc-text">1.1 HTML 页面加载渲染的过程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-HTML渲染过程的一些特点"><span class="toc-text">1.2 HTML渲染过程的一些特点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-css-阻塞和-js-阻塞"><span class="toc-text">1.3 css 阻塞和 js 阻塞</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-3-1-CSS阻塞"><span class="toc-text">1.3.1 CSS阻塞</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-3-2-JS阻塞"><span class="toc-text">1.3.2 JS阻塞</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#二、资源的压缩与合并"><span class="toc-text">二、资源的压缩与合并</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-文件合并"><span class="toc-text">2.1 文件合并</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-css、js-及-HTML压缩"><span class="toc-text">2.2 css、js 及 HTML压缩</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-1-CSS压缩"><span class="toc-text">2.2.1 CSS压缩</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-2-JS压缩"><span class="toc-text">2.2.2 JS压缩</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-3-HTML压缩"><span class="toc-text">2.2.3 HTML压缩</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-http-清求的过程及潜在的性能优化点"><span class="toc-text">2.3 http 清求的过程及潜在的性能优化点</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#三、图片相关的优化"><span class="toc-text">三、图片相关的优化</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1-不同格式图片常用的业务场景"><span class="toc-text">3.1 不同格式图片常用的业务场景</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-图片压缩几种方法-雪碧图、Image-inline"><span class="toc-text">3.2 图片压缩几种方法-雪碧图、Image inline</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-1-使用矢量图"><span class="toc-text">3.2.1 使用矢量图</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-2-在安卓下使用webp"><span class="toc-text">3.2.2 在安卓下使用webp</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#四、-懒加载与预加载"><span class="toc-text">四、 懒加载与预加载</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1-懒加载原理"><span class="toc-text">4.1 懒加载原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2-预加载原理"><span class="toc-text">4.2 预加载原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-3-懒加载、预加载使用场景"><span class="toc-text">4.3 懒加载、预加载使用场景</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-4-预加载原生-js-和-PreloadJS-实现"><span class="toc-text">4.4 预加载原生 js 和 PreloadJS 实现</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#五、缓存"><span class="toc-text">五、缓存</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#六、重绘与回流"><span class="toc-text">六、重绘与回流</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#6-1-什么是重绘与回流"><span class="toc-text">6.1 什么是重绘与回流</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#6-1-1-重绘"><span class="toc-text">6.1.1 重绘</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-1-2-回流"><span class="toc-text">6.1.2 回流</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-2-避免重绘回流的两种方法"><span class="toc-text">6.2 避免重绘回流的两种方法</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-3-css-性能让-Javacript-变慢？"><span class="toc-text">6.3 css 性能让 Javacript 变慢？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-4-案例解析-重绘、回流及图层"><span class="toc-text">6.4 案例解析-重绘、回流及图层</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-5-实战优化点总结"><span class="toc-text">6.5 实战优化点总结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#七、浏览器存储"><span class="toc-text">七、浏览器存储</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#7-1-cookies"><span class="toc-text">7.1 cookies</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-2-LocalStorage、SessionStorage"><span class="toc-text">7.2 LocalStorage、SessionStorage</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#7-2-1-LocalStorage"><span class="toc-text">7.2.1 LocalStorage</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#7-2-2-SessionStorage"><span class="toc-text">7.2.2 SessionStorage</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-3-IndexedDB"><span class="toc-text">7.3 IndexedDB</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-4-案例解析"><span class="toc-text">7.4 案例解析</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-5-PWA与Service-Workers"><span class="toc-text">7.5 PWA与Service Workers</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#7-5-1-PWA"><span class="toc-text">7.5.1 PWA</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#7-5-2-Service-Workers"><span class="toc-text">7.5.2 Service Workers</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-6-Service-Workers-离线应用"><span class="toc-text">7.6 Service Workers-离线应用</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#八、移动H5前端性能优化指南"><span class="toc-text">八、移动H5前端性能优化指南</span></a></li></ol>
  </div>
  




<div class="content content-post CENTER">
   <!-- canvas 彩带 -->
<canvas id="evanyou" width="1302" height="678" style="position: fixed;width: 100%;height: 100%;top: 0;left:0;z-index:-1;"></canvas>

<article id="post-fed-performance-optimization" class="article article-type-post" itemprop="blogPost">
  <header class="article-header" style="position:relative;">
    <h1 class="post-title">图解前端性能优化</h1>

    <div class="article-meta">
      <span>
        <i class="icon-calendar"></i>
        <span>2018.01.12</span>
      </span>

      
        <span class="article-author">
          <i class="icon-user"></i>
          <span>Poetry</span>
        </span>
      

      
  <span class="article-category">
    <i class="icon-list"></i>
    <a class="article-category-link" href="/categories/Front-End/">Front-End</a>
  </span>



      

      
      <i class="fa fa-eye"></i> 
        <span id="busuanzi_container_page_pv">
           &nbsp热度 <span id="busuanzi_value_page_pv">
           <i class="fa fa-spinner fa-spin"></i></span>℃
        </span>
      
      
       
          <span class="post-count">
            <i class="fa fa-file-word-o"></i>&nbsp
            <span>字数统计 346字</span>
          </span>

          <span class="post-count">
            <i class="fa fa-columns"></i>&nbsp
            <span>阅读时长 1分</span>
          </span>
      
      
    </div>

    <i class="iconfont" id="toc-eye" style="display:inline-block;color:#b36619;position:absolute;top:0;right:0;cursor:pointer;
    font-size: 24px;">&#xe61c;</i>

  </header>

  <div class="article-content">
    
      <div id="container">
        <h2 id="一、css和js的装载与执行"><a href="#一、css和js的装载与执行" class="headerlink" title="一、css和js的装载与执行"></a>一、css和js的装载与执行</h2><h3 id="1-1-HTML-页面加载渲染的过程"><a href="#1-1-HTML-页面加载渲染的过程" class="headerlink" title="1.1 HTML 页面加载渲染的过程"></a>1.1 HTML 页面加载渲染的过程</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/119.png" alt></p>
<h3 id="1-2-HTML渲染过程的一些特点"><a href="#1-2-HTML渲染过程的一些特点" class="headerlink" title="1.2 HTML渲染过程的一些特点"></a>1.2 HTML渲染过程的一些特点</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/120.png" alt></p>
<h3 id="1-3-css-阻塞和-js-阻塞"><a href="#1-3-css-阻塞和-js-阻塞" class="headerlink" title="1.3 css 阻塞和 js 阻塞"></a>1.3 css 阻塞和 js 阻塞</h3><h4 id="1-3-1-CSS阻塞"><a href="#1-3-1-CSS阻塞" class="headerlink" title="1.3.1 CSS阻塞"></a>1.3.1 CSS阻塞</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/121.png" alt></p>
<h4 id="1-3-2-JS阻塞"><a href="#1-3-2-JS阻塞" class="headerlink" title="1.3.2 JS阻塞"></a>1.3.2 JS阻塞</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/122.png" alt></p>
<h2 id="二、资源的压缩与合并"><a href="#二、资源的压缩与合并" class="headerlink" title="二、资源的压缩与合并"></a>二、资源的压缩与合并</h2><h3 id="2-1-文件合并"><a href="#2-1-文件合并" class="headerlink" title="2.1 文件合并"></a>2.1 文件合并</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/123.png" alt></p>
<h3 id="2-2-css、js-及-HTML压缩"><a href="#2-2-css、js-及-HTML压缩" class="headerlink" title="2.2 css、js 及 HTML压缩"></a>2.2 css、js 及 HTML压缩</h3><h4 id="2-2-1-CSS压缩"><a href="#2-2-1-CSS压缩" class="headerlink" title="2.2.1 CSS压缩"></a>2.2.1 CSS压缩</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/124.png" alt></p>
<h4 id="2-2-2-JS压缩"><a href="#2-2-2-JS压缩" class="headerlink" title="2.2.2 JS压缩"></a>2.2.2 JS压缩</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/125.png" alt></p>
<h4 id="2-2-3-HTML压缩"><a href="#2-2-3-HTML压缩" class="headerlink" title="2.2.3 HTML压缩"></a>2.2.3 HTML压缩</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/126.png" alt></p>
<h3 id="2-3-http-清求的过程及潜在的性能优化点"><a href="#2-3-http-清求的过程及潜在的性能优化点" class="headerlink" title="2.3 http 清求的过程及潜在的性能优化点"></a>2.3 http 清求的过程及潜在的性能优化点</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/127.png" alt></p>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/128.png" alt></p>
<h2 id="三、图片相关的优化"><a href="#三、图片相关的优化" class="headerlink" title="三、图片相关的优化"></a>三、图片相关的优化</h2><h3 id="3-1-不同格式图片常用的业务场景"><a href="#3-1-不同格式图片常用的业务场景" class="headerlink" title="3.1 不同格式图片常用的业务场景"></a>3.1 不同格式图片常用的业务场景</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/129.png" alt></p>
<h3 id="3-2-图片压缩几种方法-雪碧图、Image-inline"><a href="#3-2-图片压缩几种方法-雪碧图、Image-inline" class="headerlink" title="3.2 图片压缩几种方法-雪碧图、Image inline"></a>3.2 图片压缩几种方法-雪碧图、Image inline</h3><h4 id="3-2-1-使用矢量图"><a href="#3-2-1-使用矢量图" class="headerlink" title="3.2.1 使用矢量图"></a>3.2.1 使用矢量图</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/130.png" alt></p>
<h4 id="3-2-2-在安卓下使用webp"><a href="#3-2-2-在安卓下使用webp" class="headerlink" title="3.2.2 在安卓下使用webp"></a>3.2.2 在安卓下使用webp</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/131.png" alt></p>
<h2 id="四、-懒加载与预加载"><a href="#四、-懒加载与预加载" class="headerlink" title="四、 懒加载与预加载"></a>四、 懒加载与预加载</h2><h3 id="4-1-懒加载原理"><a href="#4-1-懒加载原理" class="headerlink" title="4.1 懒加载原理"></a>4.1 懒加载原理</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/132.png" alt></p>
<h3 id="4-2-预加载原理"><a href="#4-2-预加载原理" class="headerlink" title="4.2 预加载原理"></a>4.2 预加载原理</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/133.png" alt></p>
<h3 id="4-3-懒加载、预加载使用场景"><a href="#4-3-懒加载、预加载使用场景" class="headerlink" title="4.3 懒加载、预加载使用场景"></a>4.3 懒加载、预加载使用场景</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/134.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/135.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/136.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/137.png" alt></p>
<h3 id="4-4-预加载原生-js-和-PreloadJS-实现"><a href="#4-4-预加载原生-js-和-PreloadJS-实现" class="headerlink" title="4.4 预加载原生 js 和 PreloadJS 实现"></a>4.4 预加载原生 js 和 PreloadJS 实现</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/138.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/139.png" alt></p>
<h2 id="五、缓存"><a href="#五、缓存" class="headerlink" title="五、缓存"></a>五、缓存</h2><p><img src="https://poetries1.gitee.io/img-repo/2019/10/140.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/141.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/142.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/143.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/144.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/145.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/146.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/147.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/148.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/149.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/150.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/151.png" alt></p>
<h2 id="六、重绘与回流"><a href="#六、重绘与回流" class="headerlink" title="六、重绘与回流"></a>六、重绘与回流</h2><h3 id="6-1-什么是重绘与回流"><a href="#6-1-什么是重绘与回流" class="headerlink" title="6.1 什么是重绘与回流"></a>6.1 什么是重绘与回流</h3><h4 id="6-1-1-重绘"><a href="#6-1-1-重绘" class="headerlink" title="6.1.1 重绘"></a>6.1.1 重绘</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/152.png" alt></p>
<h4 id="6-1-2-回流"><a href="#6-1-2-回流" class="headerlink" title="6.1.2 回流"></a>6.1.2 回流</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/153.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/154.png" alt></p>
<h3 id="6-2-避免重绘回流的两种方法"><a href="#6-2-避免重绘回流的两种方法" class="headerlink" title="6.2 避免重绘回流的两种方法"></a>6.2 避免重绘回流的两种方法</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/155.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/156.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/157.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/158.png" alt></p>
<h3 id="6-3-css-性能让-Javacript-变慢？"><a href="#6-3-css-性能让-Javacript-变慢？" class="headerlink" title="6.3 css 性能让 Javacript 变慢？"></a>6.3 css 性能让 Javacript 变慢？</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/159.png" alt></p>
<h3 id="6-4-案例解析-重绘、回流及图层"><a href="#6-4-案例解析-重绘、回流及图层" class="headerlink" title="6.4 案例解析-重绘、回流及图层"></a>6.4 案例解析-重绘、回流及图层</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/160.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/161.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/162.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/163.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/164.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/165.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/166.png" alt></p>
<h3 id="6-5-实战优化点总结"><a href="#6-5-实战优化点总结" class="headerlink" title="6.5 实战优化点总结"></a>6.5 实战优化点总结</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/167.png" alt></p>
<h2 id="七、浏览器存储"><a href="#七、浏览器存储" class="headerlink" title="七、浏览器存储"></a>七、浏览器存储</h2><h3 id="7-1-cookies"><a href="#7-1-cookies" class="headerlink" title="7.1 cookies"></a>7.1 cookies</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/168.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/169.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/170.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/171.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/172.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/173.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/174.png" alt></p>
<h3 id="7-2-LocalStorage、SessionStorage"><a href="#7-2-LocalStorage、SessionStorage" class="headerlink" title="7.2 LocalStorage、SessionStorage"></a>7.2 LocalStorage、SessionStorage</h3><h4 id="7-2-1-LocalStorage"><a href="#7-2-1-LocalStorage" class="headerlink" title="7.2.1 LocalStorage"></a>7.2.1 LocalStorage</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/175.png" alt></p>
<h4 id="7-2-2-SessionStorage"><a href="#7-2-2-SessionStorage" class="headerlink" title="7.2.2 SessionStorage"></a>7.2.2 SessionStorage</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/176.png" alt></p>
<h3 id="7-3-IndexedDB"><a href="#7-3-IndexedDB" class="headerlink" title="7.3 IndexedDB"></a>7.3 IndexedDB</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/177.png" alt></p>
<h3 id="7-4-案例解析"><a href="#7-4-案例解析" class="headerlink" title="7.4 案例解析"></a>7.4 案例解析</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/178.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/179.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/180.png" alt></p>
<h3 id="7-5-PWA与Service-Workers"><a href="#7-5-PWA与Service-Workers" class="headerlink" title="7.5 PWA与Service Workers"></a>7.5 PWA与Service Workers</h3><h4 id="7-5-1-PWA"><a href="#7-5-1-PWA" class="headerlink" title="7.5.1 PWA"></a>7.5.1 PWA</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/181.png" alt></p>
<h4 id="7-5-2-Service-Workers"><a href="#7-5-2-Service-Workers" class="headerlink" title="7.5.2 Service Workers"></a>7.5.2 Service Workers</h4><p><img src="https://poetries1.gitee.io/img-repo/2019/10/182.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/183.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/184.png" alt></p>
<h3 id="7-6-Service-Workers-离线应用"><a href="#7-6-Service-Workers-离线应用" class="headerlink" title="7.6 Service Workers-离线应用"></a>7.6 Service Workers-离线应用</h3><p><img src="https://poetries1.gitee.io/img-repo/2019/10/185.png" alt><br><img src="https://poetries1.gitee.io/img-repo/2019/10/186.png" alt></p>
<h2 id="八、移动H5前端性能优化指南"><a href="#八、移动H5前端性能优化指南" class="headerlink" title="八、移动H5前端性能优化指南"></a>八、移动H5前端性能优化指南</h2><p><img src="https://camo.githubusercontent.com/db045941b5adebe26eae1202b9286fe8c39e5fa2/687474703a2f2f75706c6f61642d696d616765732e6a69616e7368752e696f2f75706c6f61645f696d616765732f3934383631342d313735326635633839393363633161302e6a7065673f696d6167654d6f6772322f6175746f2d6f7269656e742f7374726970253743696d61676556696577322f322f772f31323430" alt></p>

      </div>
    
  </div>

</article>

<button class="assist-btn2 circle" id="assist_btn2" title="点亮屏幕" style="left: 27px; top: 152px;">
  <i class="iconfont" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>
<button class="assist-btn1 circle" id="assist_btn1" title="关闭屏幕亮度" style="left: 27px; top: 152px;">
  <i class="iconfont toc-title" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>


<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>	

<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
  const btw = new BTWPlugin();
  btw.init({
    id: "container",
    blogId: "22699-1592137983091-414",
    name: "前端进阶之旅",
    qrcode: "https://poetries1.gitee.io/img-repo/2020/06/qrcode.jpg",
    keyword: "3a3b3c",
  });
</script>

<script type="text/javascript">

// white theme
var body = {color: "#555", background: "#000"};
var a_tag = {color: "#222"};
var header = { background: "#222"};
var logo_line_i = {background: "#222"};
// var post_code = {background: "#eee", color: "#222"};

function switch_theme() {
 $("body").css(body);
 $("a:not('.links-of-author-item a, .site-state-item a, .site-state-posts a, .feed-link a, .motion-element a, .post-tags a, .show-commit-cls a, #donate_board a')").css(a_tag);
 $(".header, .footer").css(header);
 $(".logo-line-before i, .logo-line-after i").css(logo_line_i);
 //$(".post code").css(post_code);
 $("#idhyt-surprise-ball #idhyt-surprise-ball-animation .drag").css(a_tag);
 $(".post-title-link, .posts-expand .post-meta, .post-comments-count, .disqus-comment-count, .post-category a, .post-nav-next a, .post-nav-item a").css(a_tag);
 
 // $("code").css({color: '#c5c8c6', background: '#1d1f21'});
 //$("#assist_btn1").hide(1500);
}

$(function () {
$("#assist_btn2").css("display","none");
 $("#assist_btn1").click(function() {
     switch_theme();
$("div#toc.toc-article").css({
 "background":"#eaeaea",
 "opacity":1
});
$(".toc-article ol").show();
$("#toc.toc-article .toc-title").css("color","#a98602");
$("#assist_btn1").css("display","none");
$("#assist_btn2").css("display","block");
 });
$("#assist_btn2").click(function() {
$("#assist_btn2").css("display","none");
$("#assist_btn1").css("display","block");
$("body").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
     $(".header, .footer").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
$(".toc-article ol").toggle(1000);
 });
});


//背景随机

var Y, O, E, L, B, C, T, z, N, S, A, I;
!function() {
var e = function() {
for (O.clearRect(0, 0, L, B), T = [{
x: 0,
y: .7 * B + C
}, {
x: 0,
y: .7 * B - C
}]; T[1].x < L + C;) t(T[0], T[1])
}, t = function(e, t) {
O.beginPath(), O.moveTo(e.x, e.y), O.lineTo(t.x, t.y);
var n = t.x + (2 * I() - .25) * C,
 r = a(t.y);
O.lineTo(n, r), O.closePath(), N -= S / -50, O.fillStyle = "#" + (127 * A(N) + 128 << 16 | 127 * A(N + S / 3) + 128 << 8 | 127 * A(N + S / 3 * 2) + 128).toString(16), O.fill(), T[0] = T[1], T[1] = {
 x: n,
 y: r
}
}, a = function n(e) {
var t = e + (2 * I() - 1.1) * C;
return t > B || t < 0 ? n(e) : t
};
Y = document.getElementById("evanyou"), O = Y.getContext("2d"), E = window.devicePixelRatio || 1, L = window.innerWidth, B = window.innerHeight, C = 90, z = Math, N = 0, S = 2 * z.PI, A = z.cos, I = z.random, Y.width = L * E, Y.height = B * E, O.scale(E, E), O.globalAlpha = .6, document.onclick = e, document.ontouchstart = e, e()
}()

   
$("#toc-eye").click(function(){
$("#toc.toc-article").toggle(1000);
});

</script>


   
  <div class="text-center donation">
    <div class="inner-donation">
      <span class="btn-donation">支持一下</span>
      <div class="donation-body">
        <div class="tip text-center">扫一扫，支持poetries</div>
        <ul>
        
          <li class="item">
            
              <span>微信扫一扫</span>
            
            <img src="/images/weixin.jpg" alt="">
          </li>
        
          <li class="item">
            
              <span>支付宝扫一扫</span>
            
            <img src="/images/zhifubao.jpg" alt="">
          </li>
        
        </ul>
      </div>
    </div>
  </div>


   
  <div class="box-prev-next clearfix">
    <a class="show pull-left" href="/2018/01/12/echart/">
        <i class="icon icon-angle-left"></i>
    </a>
    <a class="show pull-right" href="/2018/01/27/mobile-device-size/">
        <i class="icon icon-angle-right"></i>
    </a>
  </div>




</div>


  <a id="backTop" class="back-top">
    <i class="icon-angle-up"></i>
  </a>




  <div class="modal" id="modal">
  <span id="cover" class="cover hide"></span>
  <div id="modal-dialog" class="modal-dialog hide-dialog">
    <div class="modal-header">
      <span id="close" class="btn-close">关闭</span>
    </div>
    <hr>
    <div class="modal-body">
      <ul class="list-toolbox">
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/archives/"
              rel="noopener noreferrer"
              target="_self"
              >
              博客
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/categories/"
              rel="noopener noreferrer"
              target="_self"
              >
              分类
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/tags/"
              rel="noopener noreferrer"
              target="_self"
              >
              标签
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/search/"
              rel="noopener noreferrer"
              target="_self"
              >
              搜索
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/link/"
              rel="noopener noreferrer"
              target="_self"
              >
              友链
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/about/"
              rel="noopener noreferrer"
              target="_self"
              >
              关于
            </a>
          </li>
        
      </ul>

    </div>
  </div>
</div>



  
      <div class="fexo-comments comments-post">
    

    

    
    

    

    
    

    

<!-- Gitalk评论插件通用代码 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
  clientID: '5567a2c4abb858009d96',
  clientSecret: 'b9039ec056cf5c2346b3cdb63308a28c163f91e5',
  repo: 'poetries.github.io',
  owner: 'poetries',
  // 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
  // 50个字符串则会报错.
  // id: location.pathname.split('/').pop().substring(0, 49),
  id: location.pathname,
  admin: ['poetries'],
  // facebook-like distraction free mode
  distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
<!-- Gitalk代码结束 -->



  </div>

  

  <script type="text/javascript">
  function loadScript(url, callback) {
    var script = document.createElement('script')
    script.type = 'text/javascript';

    if (script.readyState) { //IE
      script.onreadystatechange = function() {
        if (script.readyState == 'loaded' ||
          script.readyState == 'complete') {
          script.onreadystatechange = null;
          callback();
        }
      };
    } else { //Others
      script.onload = function() {
        callback();
      };
    }

    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  window.onload = function() {
    loadScript('/js/bundle.js?235683', function() {
      // load success
    });
  }
</script>


  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
 
  
</body>
</html>
